package org.grow.cooldown.ScoreModule.entity;

import org.grow.cooldown.ScoreModule.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//
@Configuration
public class ScoreConfig implements WebMvcConfigurer {
    @Autowired
    CommonCookieIntercepter commonCookieIntercepter;
    @Autowired
    HolderIntercepter holderIntercepter;
    @Autowired
    LoginIntercepter loginIntercepter;
    @Autowired
    LogoutIntercepter logoutIntercepter;
    @Autowired
    SessionAuthIntercepter sessionAuthIntercepter;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {


        registry.addInterceptor(loginIntercepter)
                .order(10).addPathPatterns("/login");
        registry.addInterceptor(logoutIntercepter)
                .order(11).addPathPatterns("/logout");
        registry.addInterceptor(sessionAuthIntercepter)
                .order(87).addPathPatterns("/score/**");
        registry.addInterceptor(holderIntercepter)
                .order(88).addPathPatterns("/score/*");
        registry.addInterceptor(commonCookieIntercepter)
                .order(100).addPathPatterns("/score/**");

    }
}
